import { Pixijsvue } from "./main";

class Hook {
    private hooks: Record<string, Array<Function>> = {
        beforeCreate: [],
        created: [],
        beforeMounte: [],
        mounted: []
    };
    constructor() {

    }
    public addHooks(hookName: string, hook: Function | undefined | null) {
        if (this.hooks[hookName] && hook) {
            this.hooks[hookName].push(hook);
        }
    }
    public useHooks(vm: Pixijsvue, hookName: string) {
        if (this.hooks[hookName]) {
            this.hooks[hookName].forEach(hook => {
                hook.call(vm);
            })
        }
    }
}

export { Hook }